package week4.homework;//**********************************************************************************
// Acount.java   Author:Duanzhixuan
//
//  Represents a bank account with basic service such as deposit and withdraw.
//*********************************************************************************
import java.text.NumberFormat;
import java.util.Random;

public class Account
{
    private final double RATE  = 0.035;//interest rate of 3.5%

private long accNumber;
private double balance;
private String name;

//----------------------------------------------------------------------------------------------------
//  Set up  the accoune by defining its owner , account number, and intial balance.
//---------------------------------------------------------------------------------------------------
public Account(String owner, long account, double initial)
{
name=owner;
accNumber= account;
balance =initial;
}
//------------------------------------------------------------------------------------------------------
    // Deposits the specified amount into the account.Retuens the new balance.
    //---------------------------------------------------------------------------------------------------
    public double deposit(double amount)
    {
        balance =balance+amount;
        return balance;

    }
    //---------------------------------------------------------------------------------------------------------------
    //  Withdraw the specified amount from the account . Returns the new balance.
    //---------------------------------------------------------------------------------------------------------------
    public double withdraw(double amount,double fee)
    {
        balance = balance - amount - fee;
      return  balance;
    }
    //---------------------------------------------------------------------------------------------------
    // Add interest to the account and returns the new balance.
    //----------------------------------------------------------------------------------------------------
    public double addinterest()
    {
        balance += (balance* RATE);
        return balance;

    }
    //----------------------------------------------------------------------------
    //  Returbs the current balance of the account.
    //-------------------------------------------------------------------------------
    public double getBalance()
    {
        return balance;
    }
    //--------------------------------------------------------------------------------------
    // Returns a one-line description of the account as a string.
    //-------------------------------------------------------------------------------------
    public String toString()
    {
        NumberFormat fmt= NumberFormat.getCurrencyInstance();
        return accNumber+"\t"+name+"\t"+fmt.format(balance);
    }


 public Account(String owner, long account)
  {
  name=owner;
  accNumber= account;
  balance =0;}
}

